import request from '@/utils/request.js'
// import {useTokenStore} from "@/stores/token.js";
//[31][32]	教师/管理员查看某课堂中所有学生

export const findStudentInClassService = (classID) => {
    const token = localStorage.getItem('token');

    return request.get(`/student/findallstudentbyclass/${classID}`, {
        headers: { 'Authorization': token }
    });
};
//[18][19]	教师/管理员删除课堂与学生之间的联系``
export const deleteStudentRealationshipService = (classID,studentID) => {
    const token = localStorage.getItem('token');

    return request.delete(`/student/{classID}/{studentID}`, {
        headers: { 'Authorization': token }
    });
};
//[20][21]	管理员/老师将学生批量从课堂移除
export const deleteMassStudentFromClassService = (classStuList) => {
    const token = localStorage.getItem('token');

    return request.post('/student/classstu/del/batch', classStuList, {
        headers: { 'Authorization': token }
    });
};
//[28][29]	管理员/教师添加单个学生
export const addSingleStudentService = (studentInfo, classID) => {
    const token = localStorage.getItem('token');

    return request.post('/student/save', studentInfo, {
        headers: {
            'Authorization': token,
            'Content-Type': 'application/json'
        },
        params: {
            classID
        }
    });
};
//[30][31]	教师通过课堂分页模糊查询学生
export const findStudentsInClassService = (classID, page, size, studentID, studentName) => {
    const token = localStorage.getItem('token');

    return request.get('/student/page/class', {
        headers: { 'Authorization': token },
        params: {
            classID,
            page,
            size,
            studentID,
            studentName
        }
    });
};
//[33][35]	教师删除课堂助教
export const deleteTAService = (classID, executingteacherID, teacherID) => {
    const token = localStorage.getItem('token');

    return request.delete(`/teacher/deleteTA/${classID}/${executingteacherID}/${teacherID}`, {
        headers: { 'Authorization': token }
    });
};
//[36]	教师删除课堂中的学生
export const deleteStudentFromClass = (classID, studentID) => {
    const token = localStorage.getItem('token');

    return request.delete(`/teacher/deleteStudent/${classID}/${studentID}`, {
        headers: { 'Authorization': token }
    });
};
//[34][37]	教师创建课堂
export const createClass = (className, teacherID, courseNameID) => {
    const token = localStorage.getItem('token');

    return request.post('/teacher/create/class', {
        className: className,
        teacherID: teacherID,
        courseNameID: courseNameID
    }, {
        headers: { 'Authorization': token }
    });
};
//[36][39]	教师删除课堂
export const deleteClass = (classID) => {
    const token = localStorage.getItem('token');

    return request.post('/teacher/deleteclass', {
        classID: classID
    }, {
        headers: { 'Authorization': token }
    });
};
//[37][40]	管理员/教师查看某教师创建的所有课堂
export const findAllCreatedClasses = (teacherID) => {
    const token = localStorage.getItem('token');

    return request.get(`/teacher/findallcreate/${teacherID}`, {
        headers: { 'Authorization': token }
    });
};

//[38][42]	教师查看某教师加入的所有课堂
export const findAllJoinedClasses = () => {
    const token = localStorage.getItem('token');

    return request.get('/teacher/findalljoinforteacher', {
        headers: { 'Authorization': token }
    });
};
//[39][44]	管理员/教师某课堂下所有教师
export const findAllTeachersInClassService = (classID) => {
    const token = localStorage.getItem('token');

    return request.get(`/teacher/findallteacher/${classID}`, {
        headers: { 'Authorization': token }
    });
};

//[40][45]	管理员/教师分页模糊查询课堂信息
export const pageForClassService = (pageNum, pageSize, classID, className, teacherID, courseID) => {
    const token = localStorage.getItem('token');

    return request.get(`/teacher/pageforclass`, {
        headers: { 'Authorization': token },
        params: {
            pageNum: pageNum,
            pageSize: pageSize,
            classID: classID,
            className: className,
            teacherID: teacherID,
            courseID: courseID
        }
    });
};

//[41][46]	教师给某个课堂添加助教
export const saveTAForTeacherService = (teacherID, teacherName, classID) => {
    const token = localStorage.getItem('token');

    return request.post(`/teacher/saveTAforteacher`, {
        teacherID: teacherID,
        teacherName: teacherName,
        classID: classID
    }, {
        headers: { 'Authorization': token }
    });
};

//[43][48]	教师更新课堂信息
export const updateClassService = (classID, className, teacherID, courseID) => {
    const token = localStorage.getItem('token');

    return request.post(`/teacher/updateclass`, {
        classID: classID,
        className: className,
        teacherID: teacherID,
        courseID: courseID
    }, {
        headers: { 'Authorization': token }
    });
};

